package com.shop.controller;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebFilter("/*")
public class LodinFilter extends HttpFilter{
	
	@Override
	protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		String uri = request.getRequestURI();
		if(uri.contains("login.jsp") || uri.contains("login.do")) {
			super.doFilter(request, response, chain);
			return;
		}
		
		if(request.getSession().getAttribute("loginAdmin") != null) {
			super.doFilter(request, response, chain);
			return;
		}
		response.sendRedirect("login.jsp");
	}

}
